<?php
require_once ('libraryfiles/config.php');
$content = 'login.php';
$include = '
		<script src="' . base_url . 'js/jquery.validate.js" type="text/javascript"></script>
				';
$site_title = 'Login to account';
require_once TMP_USER_PATH;
if (isset($_SESSION ['username'])) {
	?>
<script type="text/javascript">
        window.location = "<?php echo W_ROOT; ?>"
    </script>
<?php
exit();
} else {

    if (!empty($_GET ["return_url"])) {
        $return_url = @ $_GET ["return_url"];
    } else {
        $return_url = $CURRENT_URL;
    }
    $success = isset($_GET ['success']) ? $_GET ['success'] : '';
    ?>

<script type="text/javascript">

        function checkvalidation() {
            var txtname = document.forms['formLogin']['email_add'].value;
            var pass = document.forms['formLogin']['passwd'].value;
            if (document.forms['formLogin']['accounttype'][0].checked == false && document.forms['formLogin']['accounttype'][1].checked == false) {
                alert("Please select your Account type!");
                return false;
            } else if (txtname == null || txtname == "") {
                alert("Please input Email Address!");
                document.forms['formLogin']['email_add'].focus();
                return false;
            } else if (pass == null || pass == "") {
                alert("Please input password!");
                document.forms['formLogin']['passwd'].focus();
                return false;
            }

        }

        $().ready(function() {
            $('#Form').validate({
                rules: {
                    accounttype: {
                        required: true
                    },
                    passwd: {
                        required: true,
                        minlength: 6
                    },
                    email_add: {
                        required: true,
                        email: true
                    },
                },
                messages: {
                    passwd: {
                        required: "<?php echo $lang['INPUTPASSWORD']; ?>",
                        minlength: "<?php echo $lang['INPUT_PASSWORD_MIN']; ?>"
                    },
                    email_add: "<?php echo $lang['EMAILSMSS']; ?>",
                }
            });
        });
    </script>

<!--Messsage-->
<?php
if (isset($_GET ['success']) != "") {
        $message = $_GET ['success'];
    } else {
        $message = '';
    }

    // if we got an error then we display it here
    if ($message) {
        ?>
<div class="alert alert-success fade in">
	<button type="button" class="close" data-dismiss="alert">&times;</button>
	<h3 class="alert-heading">
		<!--Well done! You successfully.-->
		<?php echo $lang['SUCCESSSMS']; ?>
	</h3>
	<p style="font-size: 16px;">
		<blink>
			<?php echo @$lang[$message]; ?>
		</blink>
	</p>
</div>
<?php
    }
    ?>
<!--End Message-->
<!--Messsage-->
<?php if (!empty($_GET['message'])) { ?>
<div class="row-fluid">
	<div class="span12">
		<?php
		if (isset($_GET ['message']) != "") {
                    $message = $_GET ['message'];
                } else {
                    $message = '';
                }
                // if we got an error then we display it here
                if ($message) {
                    ?>
		<div class="alert alert-block fade in">
			<button type="button" class="close" data-dismiss="alert">&times;</button>
			<h3 class="alert-heading">
				<!--Heads up! This alert needs your attention-->
				<?php echo $lang['HEADE_UP_ALERT']; ?>
			</h3>
			<p style="font-size: 16px;">
				<blink>
					<?php echo @$lang[$message]; ?>
				</blink>
			</p>
		</div>
		<?php
                }
                ?>
	</div>
</div>
<!--End Message-->
<!--Error-->
<?php
    }
    $CURRENT_URL = W_ROOT;
    if (isset($_GET ['error']) != "") {
        $error = isset($_GET ['error']) ? $_GET ['error'] : '';
        switch ($error) {
        	case 1 :
        		$message = $lang ['EMAILADDINVALID'];
        		break;
        	case 2 :
        		$message = 'Email Address &amp; Password is Invalid';
        		break;
        	case 3 :
        		$message = $lang ['PLSSELECTTHEACCOUNT'];
        		break;
        	case 4 :
        		$message = "Missing provider application credentials.";
        		break;
        	case 5 :
        		$message = "Authentification failed. The user has canceled the authentication or the provider refused the connection.";
        		break;

        	default :
        		$message = "Unspecified error!";
        }
    } else {
        $message = '';
    }
    ?>

<!--end Error-->

<!--test foundation formlogin-->
<?php if (!empty($_GET['error'])) { ?>
<div class="row-fluid">
	<div class="span12">
		<?php
		$CURRENT_URL = W_ROOT;
		if (isset($_GET ['error'])) {
                    $message = $_GET ['error'];
                    ?>
		<div class="alert alert-block alert-error fade in">
			<button type="button" class="close" data-dismiss="alert">&times;</button>
			<h3 class="alert-heading">
				<!--Oh snap! You got an error!-->
				<?php echo $lang['SNAB_ERROO']; ?>
			</h3>
			<p style="font-size: 16px;">
				<blink>
					<?php echo @$lang[$message]; ?>
				</blink>
			</p>
		</div>
		<?php
                }
                ?>
	</div>
</div>
<?php } ?>
<div class="row-fluid">
	<div class="span12">
		<div class="box laster custom">
			<div class="box-heading">
				<h2>
					<?php echo $lang['LOGINTOURKHMACC']; ?>
				</h2>
			</div>
			<div class="box-content">
				<div class="product-grid" style="padding: 10px;">
					<div class="row-fluid">
						<form id="Form" name="formLogin" method="post"
							action="process_login.php?return_url=<?php echo $return_url; ?>">
							<div class="span6">


								<div class="row-fluid">
									<div class="span6">
										<label>
											<div class="accountType_left">
												<div class="left_text">
													<input type="radio" name="accounttype" value="3"
													<?php
													$accounttype = ((!empty($_COOKIE['accounttype'])) ? $_COOKIE['accounttype'] : '');
													echo ((($accounttype == 3)) ? 'checked="checked"' : '');
													?> />
													<?php echo $lang['MENU_BUYER']; ?>
												</div>
											</div>
										</label>
									</div>
									<div class="span6">
										<label>
											<div class="accountType_left">
												<div class="left_text">
													<input type="radio" name="accounttype" value="2"
													<?php
													$accounttype = ((!empty($_COOKIE['accounttype'])) ? $_COOKIE['accounttype'] : '');
													echo ((($accounttype == 2)) ? 'checked="checked"' : '');
													?> />
													<?php echo $lang['MENU_SELLER']; ?>
												</div>
											</div>
										</label>
									</div>
								</div>



								<div class="row-fluid">
									<div class="span12">
										<p id="form-login-username">
											<label for="username"> <!-- Email Address--> <?php echo $lang['LOG_EMAIL']; ?><br />
											</label>
										</p>
									</div>
									<div class="span12">

										<input type="text" class="inputform required" alt="username"
											value="<?php echo ((!empty($_COOKIE['username'])) ? $_COOKIE['username'] : ''); ?>"
											id="email_add" name="email_add" /></label>
									</div>
									<div class="clear">&nbsp;&nbsp;&nbsp;&nbsp;</div>
								</div>
								<div class="row-fluid">
									<div class="span12">
										<p id="form-login-password">
											<label class="float_left required" for="passwd"> <!--Password-->
												<?php echo $lang['LOG_PASSWORD']; ?><br />
											</label>
										</p>
									</div>
									<div class="span12">
										<input type="password" alt="password" class="inputform"
											value="<?php echo ((!empty($_COOKIE['password'])) ? $_COOKIE['password'] : ''); ?>"
											class="inputbox" id="passwd" name="passwd" /></label>
									</div>
									<div class="clear">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>

									<div class="span12">
										<a href="<?php echo W_ROOT; ?>/account/email_form.php"> <!-- Forgot your password?-->
											<?php echo $lang['LOG_FORGET']; ?>
										</a>
									</div>
									<div class="span12">
										<a href="<?php echo W_ROOT; ?>/create_account.php"> <!--Create an account-->
											<?php echo $lang['LOG_CRE_ACCOUNT']; ?>
										</a>
									</div>
									<div class="clear"></div>
									<div class="row-fluid">
										<div class="span1">
											<input type="checkbox" tabindex="3" class="checkbox"
												name="chkRemember" id="chkRemember"
												<?php echo ((!empty($_COOKIE['password'])) ? 'checked="checked"' : ''); ?>>
										</div>
										<div class="span11">
											<label class="check_box_text" for="chkRemember"> <!--Remember me-->
												<?php echo $lang['LOG_REMEMBER']; ?>
											</label>
										</div>
									</div>
									<div class="span12">
										<input type="submit"
											value="<?php echo $lang['MENU_LOGIN']; ?>"
											class="button pull-right" name="btnLogin"
											style="margin-right: 50px;" />
									</div>
									<div class="clear"></div>
								</div>
							</div>

							<!-- by facebook -->
							<div class="span6">
								<div class="row">
									<img src="<?php echo W_ROOT; ?>/images/social/or.jpg"
										style="float: left; margin-right: 30px;">
									<div class="" style="float: left;">
										<?php echo $lang['LOGINWITHYRSONET']; ?>
										<div class="clear"></div>
										<!--<div class="two column">-->
                                                                                <a href="<?php echo W_ROOT; ?>/social/social.php?provider=Facebook"><img src="<?php echo W_ROOT; ?>/images/social/facebook.png" height="40" alt="facebook"></a>   
										
									</div>
								</div>
							</div>
						</form>
						<!-- end by facebook -->
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<?php
if (isset($_GET ['error_net']) != "") {
        $error_net = $_GET ['error_net'];
        echo '<p><h5 style="color:red">' . $error_net . '</h5></p>';
    }
    ?>

<script language="JavaScript" type="text/javascript">
        document.formLogin.email_add.select();
        document.formLogin.email_add.focus();
    </script>
</div>
<?php
}
?>